package Demo1;

import java.util.Arrays;

class MyArray <T>{
    public T[] array = (T[]) new Object[10];
    public T getPos(int pos){
        return this.array[pos];
    }
    public void setVal(int pos, T val){
        this.array[pos] = val;
    }

    @Override
    public String toString() {
        return "MyArray{" +
                "array=" + Arrays.toString(array) +
                '}';
    }
}
public class Test {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setVal(0,10);
        myArray.setVal(1,20);

        MyArray<String> myArray1 = new MyArray<>();
        myArray1.setVal(2,"sad");
        myArray1.setVal(3,"saasd");

        System.out.println(myArray.toString());
        System.out.println(myArray1.toString());
    }
}
